package com.xiaolon.rpc.protocol;/*
 *   项目名称：rpc-demo
 *   文件名称：com.xiaolon.rpc.protocol.ProtocolMessageStatusEnum
 *
 *   创建人：  ZHOU XIAO LONG
 *   创建日期：2024/12/9
 *
 */

import lombok.Getter;

/**
 * 协议消息的状态枚举
 */
@Getter
public enum ProtocolMessageStatusEnum {
    OK("ok", 200),
    BAD_REQUEST("badRequest", 40),
    BAD_RESPONSE("badResponse", 50);
    private final String text;
    private final int value;

    ProtocolMessageStatusEnum(String text, int value){
        this.text = text;
        this.value =value;
    }

    /**
     * 根据value获取枚举
     * @param value
     * @return
     */
    public static ProtocolMessageStatusEnum getEnumByValue(int value){
        for (ProtocolMessageStatusEnum anEnum : ProtocolMessageStatusEnum.values()) {
            if(anEnum.value == value) return anEnum;
        }
        return null;
    }
}
